<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>摇骰子</title>
    <style type="text/css">
        img {
            width: 100px;
            height: 100px;
        }
    </style>
</head>

<body>
    <div id="d1">
        <img id='i1' src="img/摇色子/1.jpg">
    </div>
    <button type="button" onclick="star()">开始</button>
</body>
<script type="text/javascript">
    function star() {
        var img1 = document.getElementById('i1');
        var num = 0;
        var my_interval = setInterval(function() {
            var index = suiji();
            console.log(index)
            if (num == 50) {
                clearInterval(my_interval)
            }
            img1.src = `img/摇色子/` + index + `.jpg`;
            num++;
        }, 100)
    }

    function suiji() {
        while (true) {
            var num = Math.floor(Math.random() * 7);
            if (num != 0) {
                return num;
                break;
            }
        }
    }
</script>

</html>